package com.neuedu.oasystem.dao.impl;
/**
 * 数据库实现类
 * 数据访问层
 */
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.neuedu.oasystem.util.DBHelper;
import com.neuedu.oasystem.dao.IUserDao;
import com.neuedu.oasystem.entity.Users;
/**
 * 
 * @author admin
 *
 */
public class UserDaoImpl extends BaseDao implements IUserDao {

	@Override
	public boolean add(Users param) {

		return false;
	}

	@Override
	public boolean edit(Users param) {

		return false;
	}

	@Override
	public boolean deleteById(int id) {

		return false;
	}

	@Override
	public Users findById(int id) {

		return null;
	}

	@Override
	public List<Users> findAll() {
		List<Users> list = new ArrayList<Users>();
		Connection connection = null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;

		try {
			connection = getConnection();
			String sql = "select id,name,age,birthdate from users";
			pstmt = connection.prepareStatement(sql);
			rs = pstmt.executeQuery();
			while (rs.next()) {
				int id = rs.getInt("id");
				String name = rs.getString("name");
				int age = rs.getInt("age");
				Date birthDate = rs.getTimestamp("birthdate");
				Users users = new Users(id, name, age, birthDate);
				list.add(users);
			}

		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			// 数据库连接不在数据访问层关闭，而是在业务逻辑层进行关闭，
			DBHelper.closeAll(rs, pstmt, null);
		}

		return list;
	}

	@Override
	public List<Users> findByExample(Users param) {

		return null;
	}

	@Override
	public List<Users> findByPager(int page, int size) {

		return null;
	}

	@Override
	public int deleteByIds(int[] ids) {

		return 0;
	}

	@Override
	public int addAll(List<Users> useparamrs) {

		return 0;
	}

	@Override
	public int editAll(List<Users> param) {

		return 0;
		
		
	}

}
